import peewee
from peewee import *

db = MySQLDatabase(db = 'test',
                   user = 'root',
                   passwd = '',
                   )
class Price(peewee.Model): # 定义Python类结构 对应 MySQL中的一张表
    timestamp = peewee.DataTimeField(primary_key = True)
    btcusd = peewee.FloatField()

    class Meta:
        database = db
def test_peewee():
    Price.create_table()
    price = Price(timestamp='2019-06-07 13:17:18', BTCUSD='12345.67')
    price.save()

test_peewee()
